﻿// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_MST_DEPARTMENT
// * CreateDate    : 2011/8/5 23:04:50
// * Creater       : CodeSmith
// * LastChangeDate: 2011/8/5 23:04:50
// * LastChanger   : 2011/8/5 23:04:50
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using Suzsoft.Smart.EntityCore;
using ESOL.Common.Schema;

namespace ESOL.Common.Entity
{
    [Serializable]
    public partial class MstDepartmentEntity : EntityBase
    {
        public MstDepartmentTable TableSchema
        {
            get
            {
                return MstDepartmentTable.Current;
            }
        }

        public MstDepartmentEntity()
        {

        }

        public MstDepartmentEntity(DataRow dr)
        {
            if (dr == null)
            {
                return;
            }
            this.DepartmentId = Convert.ToString(CommonFunctions.ToObject(dr["DEPARTMENT_ID"]));
            this.ParentId = Convert.ToString(CommonFunctions.ToObject(dr["PARENT_ID"]));
            this.DepartmentCode = Convert.ToString(CommonFunctions.ToObject(dr["DEPARTMENT_CODE"]));
            this.DepartmentName = Convert.ToString(CommonFunctions.ToObject(dr["DEPARTMENT_NAME"]));
            this.Sequence = Convert.ToInt32(CommonFunctions.ToObject(dr["SEQUENCE"]));
            this.DeleteFlag = Convert.ToInt32(CommonFunctions.ToObject(dr["DELETE_FLAG"]));
            this.Description = Convert.ToString(CommonFunctions.ToObject(dr["DESCRIPTION"]));
            this.Manager = Convert.ToString(CommonFunctions.ToObject(dr["MANAGER"]));
        }

        public MstDepartmentEntity(DataRowView dr)
        {
            if (dr == null)
            {
                return;
            }
            this.DepartmentId = Convert.ToString(CommonFunctions.ToObject(dr["DEPARTMENT_ID"]));
            this.ParentId = Convert.ToString(CommonFunctions.ToObject(dr["PARENT_ID"]));
            this.DepartmentCode = Convert.ToString(CommonFunctions.ToObject(dr["DEPARTMENT_CODE"]));
            this.DepartmentName = Convert.ToString(CommonFunctions.ToObject(dr["DEPARTMENT_NAME"]));
            this.Sequence = Convert.ToInt32(CommonFunctions.ToObject(dr["SEQUENCE"]));
            this.DeleteFlag = Convert.ToInt32(CommonFunctions.ToObject(dr["DELETE_FLAG"]));
            this.Description = Convert.ToString(CommonFunctions.ToObject(dr["DESCRIPTION"]));
            this.Manager = Convert.ToString(CommonFunctions.ToObject(dr["MANAGER"]));
        }

        public override TableInfo OringTableSchema
        {
            get
            {
                return MstDepartmentTable.Current;
            }
        }

        #region Perporty List
        public string DepartmentId
        {
            get { return Convert.ToString(GetData(MstDepartmentTable.C_DEPARTMENT_ID)); }
            set { SetData(MstDepartmentTable.C_DEPARTMENT_ID, value); }
        }

        public string ParentId
        {
            get { return Convert.ToString(GetData(MstDepartmentTable.C_PARENT_ID)); }
            set { SetData(MstDepartmentTable.C_PARENT_ID, value); }
        }

        public string DepartmentCode
        {
            get { return Convert.ToString(GetData(MstDepartmentTable.C_DEPARTMENT_CODE)); }
            set { SetData(MstDepartmentTable.C_DEPARTMENT_CODE, value); }
        }

        public string DepartmentName
        {
            get { return Convert.ToString(GetData(MstDepartmentTable.C_DEPARTMENT_NAME)); }
            set { SetData(MstDepartmentTable.C_DEPARTMENT_NAME, value); }
        }

        public int Sequence
        {
            get { return Convert.ToInt32(GetData(MstDepartmentTable.C_SEQUENCE)); }
            set { SetData(MstDepartmentTable.C_SEQUENCE, value); }
        }

        public int DeleteFlag
        {
            get { return Convert.ToInt32(GetData(MstDepartmentTable.C_DELETE_FLAG)); }
            set { SetData(MstDepartmentTable.C_DELETE_FLAG, value); }
        }

        public string Description
        {
            get { return Convert.ToString(GetData(MstDepartmentTable.C_DESCRIPTION)); }
            set { SetData(MstDepartmentTable.C_DESCRIPTION, value); }
        }

        public string Manager
        {
            get 
            {
                string managerID = Convert.ToString(GetData(MstDepartmentTable.C_MANAGER));
                if (string.IsNullOrEmpty(managerID))
                {
                    return null;
                }
                return managerID;
            }
            set
            {
                if (string.IsNullOrEmpty(value))
                {
                    SetData(MstDepartmentTable.C_MANAGER, null); 
                }
                else
                {
                    SetData(MstDepartmentTable.C_MANAGER, value); 
                }
            }
        }

        #endregion
    }


}

